var isShow_Div_createSA = false;
var isShow_Div_Activity = false;
var isShow_Div_showAll_Activity = false;
var isShow_fieldset_configActive= false;
var isShow_fieldset_tableshowActiv= false;
var isShow_div_editActivity  = false;

function setVisiableDiv_createSA(b){
    if(b){
        jQuery("#Div_createSA").slideDown("slow", function() {
            isShow_Div_createSA = true;
        });
    }else{
        jQuery("#Div_createSA").slideUp("slow", function() {
            isShow_Div_createSA = false;
        });
    }
}
function setVisiableDiv_Activity(b){
    if(b){
        jQuery("#Div_Activity").slideDown("slow", function() {
            isShow_Div_Activity = true;
        });
    }else{
        jQuery("#Div_Activity").slideUp("slow", function() {
            isShow_Div_Activity = false;
        });
    }
}

function setVisiableDiv_showAll_Activity(b){
    if(b){
        jQuery("#Div_showAll_Activity").slideDown("slow", function() {
            isShow_Div_showAll_Activity = true;
        });
    }else{
        jQuery("#Div_showAll_Activity").slideUp("slow", function() {
            isShow_Div_showAll_Activity = false;
        });
    }
}
function setVisiableFieldset_configActive(b){
    if(b){
        jQuery("#configActive").slideDown("slow", function() {
            isShow_fieldset_configActive = true;
        });
    }else{
        jQuery("#configActive").slideUp("slow", function() {
            isShow_fieldset_configActive  = false;
        });
    }
}

function setVisiableFieldset_tableshowActiv(b){
    if(b){
        jQuery("#tableshowActiv").slideDown("slow", function() {
            isShow_fieldset_tableshowActiv = true;
        });
    }else{
        jQuery("#tableshowActiv").slideUp("slow", function() {
            isShow_fieldset_tableshowActiv  = false;
        });
    }
}

function setVisiableDiv_Activity_alert_success(text){
    jQuery("#Div_Activity_alert_success").text(text);
    jQuery("#Div_Activity_alert_success").slideDown("fast", function() {
           
        jQuery("#Div_Activity_alert_success").slideUp(3000, function() {
            
            });
    });
    
}

function setVisiableDiv_Activity_alert_warning(text){
    jQuery("#Div_Activity_alert_warning").text(text);
    jQuery("#Div_Activity_alert_warning").slideDown(3000, function() {
        jQuery("#Div_Activity_alert_warning").slideUp("slow", function() {
            
            });
    });
   
}


function setVisiableDiv_createSA_alert_warning(text){
    jQuery("#Div_createSA_alert_warning").text(text);
    jQuery("#Div_createSA_alert_warning").slideDown("fast", function() {
        jQuery("#Div_createSA_alert_warning").slideUp(3000, function() {
            
            });
    });
   
}
function setVisiableDiv_createSA_alert_success(text){
    
    jQuery("#Div_createSA_alert_success").text(text);
    jQuery("#Div_createSA_alert_success").slideDown("fast", function() {
        jQuery("#Div_createSA_alert_success").slideUp(3000, function() {
                
            });
    });
    return true;
}
function setVisiable_div_EditActivity(b){
    if(b){
        jQuery("#EditActivityDiv").show("fast",function(){
            isShow_div_editActivity = true;
        });
    }else{
        jQuery("#EditActivityDiv").hide("fast",function(){
            isShow_div_editActivity = false;
        });
    }
}

function drawHeader_Div_Activity(arrayInfor,title){
    var indexArray = arrayInfor.length;
    //alert(indexArray-1);
    var beginday = arrayInfor[0];
    var endday = arrayInfor[indexArray-1];
    var header = "<h3>All Activities begin "+beginday+" to " +endday+" of Schedule Activity : "+title+"</h3>";
    jQuery("#headerConfig").html(header);
    setDataForselect_allday(arrayInfor);
    return true;
}

function setDataForselect_allday(arrayInfor){
    var html;
    for(var i = 0 ; i < arrayInfor.length;i++){
        html = html + '<option value='+arrayInfor[i]+'>'+arrayInfor[i]+'</option>';
    }
    jQuery("#select_allday").html(html);
}

function drawTableshowActivity(arrayInfor,day){
    var lengthArray = arrayInfor.length;
    var html = "<table class='tablesorter'>";
    if(arrayInfor.length == 0 || arrayInfor == null){
        html = html + "<thead>";
        html = html + "<tr>";
        html = html + "<th style='color:blue;' >There is no Activity in day : "+ day+"</th>";
        html = html + "</tr>";
        html = html + "</thead>";
    }else{
        html = html + "<thead>";
        html = html + "<tr>";
        html = html + "<th style='color:blue;' colspan='7'>Activity in day : "+day+"</th>";
        html = html + "</tr>";
        html = html + "<tr>";
        html = html + "<th class=\"header\">Title</th> ";
        html = html + "<th class=\"header\">Talk about</th> ";
        html = html + "<th class=\"header\">Fee</th> ";
        html = html+"<th class=\"header\">Time Duration</th>";
        html = html+"<th class=\"header\">Address</th>";
        html = html+"<th class=\"header\">Max People</th>";
        html = html+"<th class=\"header\">Action</th>";
        html = html + "</tr>";
        html = html + "</thead>";//focus de met lam roi
        //ActivityArray.push(new Array(id,title,talkabout,fee,start_time,max_people,address));
        for(var i = 0 ; i < arrayInfor.length;i++){
            html = html +"<tr id='"+ arrayInfor[i][0]+"'>";            
            html = html + '<td>'+arrayInfor[i][1]+'</td>';//title
            html = html + '<td>'+arrayInfor[i][2]+'</td>';//tk
            html = html + '<td>'+arrayInfor[i][3]+'$</td>';//fee
            html = html + '<td>'+arrayInfor[i][4]+'</td>';//timeduration
            html = html + '<td>'+arrayInfor[i][6]+'</td>';
            html = html + '<td>'+arrayInfor[i][5]+' people</td>';//
            html= html + "<td>";
            html = html + '<input type="image" src="images/icn_edit.png" title="Edit" onclick="openEditActivityForm(\''+arrayInfor[i][0] +'\')"/>';
            html = html + '<input type="image" src="images/icn_trash.png" title="Tras" />';
            html= html + "</td>";
            
            html = html +"</tr>";
          
        }
    }
    html = html + "</table>";
    jQuery("#contaner_table").html(html);
   
}

function drawTypeOfActivitySelect(arrayInfor){
    var dll_html = "<a href=\"javascript:return void(0)\">"+arrayInfor[0][1]+"</a> ";
    var html = "<option value='"+arrayInfor[0][0]+"'>"+arrayInfor[0][1]+"</option>";
    for(var i = 1 ; i < arrayInfor.length;i++){
        html += "<option value='"+arrayInfor[i][0]+"'>"+arrayInfor[i][1]+"</option>";
        dll_html+="<a href=\"javascript:return void(0)\">"+arrayInfor[i][1]+"</a> ";
    }
    jQuery("#typeOfActivity").html(html);
    jQuery("#typeOfActivity_edit").html(html);
    jQuery(".cc-ddl-contents").html(dll_html);
}

function drawTableShowAllShedulerActivity(status){
    var html = "<table id='tableShowAllShedulerActivity'>";
    html = html +'<tr>';
    html = html + '<th class=\"header\">Title Conduct</th>';
    html = html + '<th class=\"header\">Duration Time</th>';
    html = html + '<th class=\"header\">Location</th>';
    html = html + '<th class=\"header\">Description</th>';
    html = html + '<th class=\"header\">Total People</th>';
    html = html + '<th class=\"header\">Action</th>';
    html = html + '</tr>';
    for(var i = 0; i < ShedulerActivityArray.length; i++ ){
        if(status == ShedulerActivityArray[i][1]){
            html = html +'<tr>';
            html = html + '<td style="width: 120px;text-align: center;">'+ShedulerActivityArray[i][2]+'</td>';
            html = html + '<td style="width: 120px;text-align: center;">'+ShedulerActivityArray[i][3]+'-'+ShedulerActivityArray[i][4]+'</td>';
            html = html + '<td style="width: 120px;text-align: center;">'+ShedulerActivityArray[i][5]+'</td>';
            html = html + '<td style="width: 120px;text-align: center;">'+ShedulerActivityArray[i][6]+'</td>';
            html = html + '<td style="width: 120px;text-align: center;">'+ShedulerActivityArray[i][7]+'</td>';
            html = html + '<td style="width: 120px;text-align: center;">'+ShedulerActivityArray[i][8]+'</td>';
            html = html +'</tr>';
        }
    }
    html = html +"</table>";
    jQuery("#").html(html);
}
function openDateChoose(id){

    jQuery('#'+id).will_pickdate({
        timePicker: false,
        format: 'd/m/Y',
        inputOutputFormat: 'd/m/Y'

    });
}
function openTimeChoose(id){

    jQuery('#'+id).will_pickdate({
        timePickerOnly: true,
        format: 'h:i-A',
        inputOutputFormat: 'h:i-A'
    });

}
function initMenu(){
    var menu_create_Sheduler = "<a onclick=\"openDiv('Div_createSA')\">New Sheduler Activity</a>";
    var menu_all_Sheduler = "<a onclick=\"openDiv('tableshowActiv')\">All Sheduler Activity</a>"
    jQuery("#Create_ShedulerActivity").html(menu_create_Sheduler);
    jQuery("#Create_ShedulerActivity").html(menu_all_Sheduler);
}

function drawAdminName(arrayInfor){
    jQuery("#admin_name").html("<a>"+arrayInfor[2]+"</a>");
}